package frameWork.util;

import java.awt.geom.Point2D;

public class Vector2D {
    public static Point2D jia(Point2D a,Point2D b){
        return new Point2D.Double(a.getX()+b.getX(),a.getY()+b.getY());
    }
    public static Point2D jian(Point2D a,Point2D b){
        return new Point2D.Double(a.getX()-b.getX(),a.getY()-b.getY());
    }
    public static double len(Point2D c){
        return Math.sqrt(c.getY()*c.getY()+c.getX()*c.getX());
    }
    public static Point2D mulit(Point2D a,double b){
        return new Point2D.Double(a.getX()*b,a.getY()*b);
    }
    public static Point2D resize(Point2D a,double b){
        double c=len(a);
        if(c<1e-8)return new Point2D.Double(0,0);
        return mulit(a,b/c);
    }
    public static double point(Point2D a,Point2D b){
        return a.getX()*b.getX()+a.getY()*b.getY();
    }
}
